import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index'
// 解决Vue路由重复点击报错问题
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location) {
	return routerPush.call(this, location).catch((err) => {});
};
Vue.use(VueRouter)

const routes = [{
		path: '/',
		component: () => import('../views/Index'),
		children: [{
			path: "/",
			name: "home",
			component: () => import('../views/home')
		}, {
			path: "/detail",
			name: "detail",
			component: () => import('../views/home/device/detail')
		}]
	},
	{
		path: '/aboutUs',
		component: Index,
		children: [{
			path: "/",
			name: "aboutUs",
			component: () => import('../views/aboutUs')
		}]
	},
	{
		path: '/device',
		component: Index,
		children: [{
			path: "/",
			name: "device",
			component: () => import('../views/device')
		}]
	},
	{
		path: '/store',
		component: Index,
		children: [{
			path: "/",
			name: "store",
			component: () => import('../views/store')
		}]
	},
	{
		path: '/serviceIdea',
		component: Index,
		children: [{
			path: "/",
			name: "serviceIdea",
			component: () => import('../views/serviceIdea')
		}]
	},
	{
		path: '/partners',
		component: Index,
		children: [{
			path: "/",
			name: "partners",
			component: () => import('../views/partners')
		}]
	},
	{
		path: '/contactInformation',
		component: Index,
		children: [{
			path: "/",
			name: "contactInformation",
			component: () => import('../views/contactInformation')
		}]
	},

]

const router = new VueRouter({
	mode: "hash",
	routes
})
router.beforeEach((to, from, next) => {
	window.scrollTo(0, 0); // 将页面滚动至顶部
	next()
})
export default router
